﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MCromwell.StaffIntranet.Core
{
    public class SpecificationCollection<T> : ISpecification<T>
    {
        protected IList<ISpecification<T>> specs = new List<ISpecification<T>>();

        public void Add(ISpecification<T> spec)
        {
            specs.Add(spec);
        }

        public DomainObjectValidationResult ResultsOf(T item)
        {
            var result = new DomainObjectValidationResult();
            foreach (var spec in specs)
                result.Merge(spec.ResultsOf(item).Results);
            return result;
        }

    }
}
